export default class util {
    constructor() {

    }
    /**
     * [判空]
     * @param  {String |Object |Array |Number}  para [null]
     * @return {Boolean}      [true | false]
     */
    isEmpty(para) {
        if (typeof (para) === "undefined") {
            return true;
        } else if (typeof (para) === "string") {
            return (para.trim() === '');
        } else if (para instanceof Array) {
            return (para.length === 0);
        } else if (typeof (para) === "object" && !(para instanceof Array)) {
            var para_name;
            for (para_name in para) {
                return false;
            }
            return true;
        } else if (typeof (para) === "number") {
            this.isEmpty(para + '');
        }
    }

    getSessionJson(key) {
        this.isEmpty(sessionStorage.getItem(key)) ? sessionStorage.setItem(key, JSON.stringify({})) : '';
        return JSON.parse(sessionStorage.getItem(key));
    }
    setSessionJson(key, json) {
        sessionStorage.setItem(key, JSON.stringify(json));
        return sessionStorage.getItem(key);
    } removeSession(key) {
        if (!this.isEmpty(key)) sessionStorage.removeItem(key);
    }
}